﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QqForm
{
    public class MessageDealGetQqListOnline : MessageDealBase
    {
        public override object ShowMessage(TcpClass tcpClass, byte[] msg)
        {
            PostQqServerBackResult backResult = new PostQqServerBackResult();
            string cmdQq = Encoding.UTF8.GetString(msg, 0, msg.Length);
            if (cmdQq.IndexOf("VER", StringComparison.Ordinal) == -1)
            {
                return null;
            }
            string[] resultArrary = cmdQq.Split('&');
            if (resultArrary[4] == "RES=20")
            {
                backResult.IsSuc = false;
                backResult.Result = "您的帐号在别处登录，您已被迫下线！";
                return backResult;
            }
            string fn = resultArrary[5].Split('=')[1];
            string[] un = resultArrary[8].Split(',');
            if (fn != "1")
            {
                new QqCommand().GetQqListIsOnlineCommand(tcpClass, un[un.Length - 2]);
            }
            backResult.IsSuc = true;
            return backResult;
        }


    }
}
